package com.fy.fyspace.model.enums.space;

public enum SpaceTypeEnum {

    /**
     * 个人空间
     */
    PERSONAL(0, "personal"),

    /**
     * 团队空间
     */
    TEAM(1, "team");

    private final int spaceType;
    private final String spaceTypeStr;

    SpaceTypeEnum(int spaceType, String spaceTypeStr) {
        this.spaceType = spaceType;
        this.spaceTypeStr = spaceTypeStr;
    }

    public int getSpaceType() {
        return spaceType;
    }

    public String getSpaceTypeStr() {
        return spaceTypeStr;
    }

    public static SpaceTypeEnum fromSpaceType(int spaceType) {
        for (SpaceTypeEnum type : values()) {
            if (type.getSpaceType() == spaceType) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown space type: " + spaceType);
    }

    public static SpaceTypeEnum fromSpaceTypeStr(String spaceTypeStr) {
        for (SpaceTypeEnum type : values()) {
            if (type.getSpaceTypeStr().equalsIgnoreCase(spaceTypeStr)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown space type: " + spaceTypeStr);
    }

    @Override
    public String toString() {
        return "SpaceTypeEnum{" +
                "spaceType=" + spaceType +
                ", spaceTypeStr='" + spaceTypeStr + '\'' +
                '}';
    }
}
